#pragma once
#include<iostream>
#include"httplib.h"
#include"./request/add_request.pb.h"
#include"./request/del_request.pb.h"
#include"./request/find_one_request.pb.h"
#include"./response/add_response.pb.h"
#include"./response/base_response.pb.h"
#include"./response/del_response.pb.h"
#include"./response/find_all_response.pb.h"
#include"./response/find_one_response.pb.h"
#include"../common/ContactException.h"
#include"../common/Utils.h"
#include"../mem/contacts.pb.h"
#include"../mem/ContactsMapper.h"
using namespace httplib;
class ContactsServer
{
public:
    ContactsMapper contactsMapper;

    void add(add_req::AddContactRequest& request,add_resp::AddContactResponse* response)const;

    void del(del_req::DelContactRequest& request,del_resp::DelContactResponse*response) const;

    void findOne(find_one_req::FindOneRequest request,find_one_resp::FindOneResponse* response)const;

    void findAll(find_all_resp::FindAllResponse*response)const;

private:
    void printAddContactsRequest(add_req::AddContactRequest& request)const;
    void buildPeopleInfo(contacts::PeopleInfo* people,add_req::AddContactRequest& request)const;
    void buildFindOneContactsResponse(const contacts::PeopleInfo& people,find_one_resp::FindOneResponse *response)const;
    void buildFindAllContactsResponse(const contacts::Contacts& contacts,find_all_resp::FindAllResponse *response)const;
};